unit constantes;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, Grids, DBGrids, StdCtrls, Buttons;

type
  TfrmConstantes = class(TForm)
    DBGrid1: TDBGrid;
    sConstantes: TDataSource;
    btnGrabar: TBitBtn;
    btnCancelar: TBitBtn;
    procedure sConstantesStateChange(Sender: TObject);
    procedure btnGrabarClick(Sender: TObject);
  private
    { Private declarations }
  public
    procedure Entrar;
  end;

var
  frmConstantes: TfrmConstantes;

implementation

uses MDatos;

{$R *.dfm}

procedure TfrmConstantes.Entrar;
begin
  Datos.cConstantes.Open;
  ShowModal;
end;

procedure TfrmConstantes.sConstantesStateChange(Sender: TObject);
begin
  btnGrabar.Enabled := Datos.cConstantes.ChangeCount > 0;
end;

procedure TfrmConstantes.btnGrabarClick(Sender: TObject);
begin
  if (Datos.cConstantes.State in [dsInsert, dsEdit]) then
    Datos.cConstantes.Post;
  if Datos.cConstantes.ChangeCount > 0 then
    if Datos.cConstantes.ApplyUpdates(0) <> 0 then
      Application.MessageBox('Error al grabar en tabla Constantes', 'Error', mb_Ok+mb_IconError);
  sConstantesStateChange(Sender);
end;

end.
